package com.jy.api.controller.admin;

import com.jy.api.dao.EmployeeDao;

import com.jy.api.domain.*;
import com.jy.api.service.EmployeeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


import java.util.*;


/**
 * Created by lihu on 2017/8/25.
 */

@RequestMapping(value = "v1/admin/", produces = "application/json;charset=utf-8")
@RestController
public class AdminCommissionController {


    @Autowired
    private EmployeeService employeeService;
    /**
     * 某员工业绩详情
     *
     * @param employeeId
     * @param storeId
     * @param year
     * @param month
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "employee-commission/{employeeId}")
    public ResponseEntity getCommissionDetails(@PathVariable String employeeId,
                                               @RequestParam(value = "storeId") String storeId,
                                               @RequestParam(value = "year", required = false) int year,
                                               @RequestParam(value = "month", required = false) int month, @RequestParam("type") String type, @RequestParam(value = "from", required = false) String from, @RequestParam(value = "to", required = false) String to
    ) {
        try {
            return ResponseEntity.ok(employeeService.getEmpSalesData(employeeId,storeId,year,month,from,to,type));
        } catch (Exception ex) {
            return new ResponseEntity("系统运行错误", HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}
